#!/bin/sh
export LANG="en_US.UTF-8"

DEVICE=/dev/ttyUSB0

DEVICE=`echo $DEVICE|cut -d "/" -f3`

PID=`ps | grep -v grep | grep "$DEVICE" | grep "pppd" | awk '{ print $1; exit }'`
if test $PID; then
	for P2P in `ifconfig | grep "Link encap" | awk '{ print $1 }'`
	do
		if test -e /var/run/$P2P.pid; then
			if test `cat /var/run/$P2P.pid` =  $PID; then
				#echo "connected"
				exit 0
			fi
		fi
	done
	#echo "connecting"
	exit 1
else
	#echo "not connected"
	exit 2
fi
